/**
 * 
 */
package com.tw.udf;

import java.io.IOException;

import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;
import org.apache.pig.data.TupleFactory;

import com.tw.utils.LogUtil;

public class LogFormat  extends EvalFunc<Tuple>{
	
	
	TupleFactory tupleFactory;
	
	public LogFormat() {
		tupleFactory = TupleFactory.getInstance();
	}
	public Tuple exec(Tuple input) throws IOException {
		if (input == null || input.size() == 0)
			return null;
		Tuple tuple = tupleFactory.newTuple();
		Tuple tuple1 = tupleFactory.newTuple();
		try {
			String log = input.get(0).toString();
			tuple = LogUtil.parseLog(tuple1,log);
		
			return tuple;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tuple;
	}
}
